package com.uestc.soft.controller;

import com.uestc.soft.pojo.Port;
import com.uestc.soft.service.PortService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
public class PortController {
    @Resource
    private PortService portService;

    @RequestMapping("/selectById")
    public Port selectById(@RequestParam Integer id) {
        return portService.selectById(id);
    }

    @RequestMapping("/hy_selectByPage")
    public Map<String, Object> hy_selectByPage(@RequestParam int page,
                                            @RequestParam int limit,
                                            String portNumber,
                                            String portProtocol,
                                            String processName) {
        return portService.hy_selectByPage(page, limit,portNumber,portProtocol,processName);
    }

    @RequestMapping("/port/hy_insert")
    public Map<String, Object> insert(@RequestBody Port port) {
        return portService.hy_insert(port);
    }

    @RequestMapping("/port/hy_deleteById")
    public Map<String, Object> hy_deleteById(@RequestParam Integer id) {
        return portService.hy_deleteById(id);
    }

    @RequestMapping("/port/updatePort")
    public Map<String, Object> updatePort(
            @RequestParam Integer id,Integer portNumber,String portProtocol,String processName,Integer numberOfHostMachines)
    {
        return portService.updatePort(id,portNumber,portProtocol,processName,numberOfHostMachines);
    }
}
